from typing import Optional, List
from datetime import datetime
from pydantic import condecimal, ConfigDict
from .base import BaseSchema

class PackageOrderBase(BaseSchema):
    work_area_id: int
    customer_profile_id: Optional[int] = None
    order_number: Optional[str] = None
    title: Optional[str] = None
    total_people: Optional[int] = None
    start_date: Optional[datetime] = None
    end_date: Optional[datetime] = None
    customer_name: Optional[str] = None
    customer_phone: Optional[str] = None
    customer_email: Optional[str] = None
    customer_company: Optional[str] = None
    tax_rate: Optional[float] = 0.09
    elevy_stamp_amount: Optional[float] = 0
    status: Optional[str] = 'draft'
    pdf_url: Optional[str] = None
    elevy_stamp_url: Optional[str] = None
    internal_notes: Optional[str] = None
    customer_notes: Optional[str] = None
    terms_conditions: Optional[str] = None

class PackageOrderCreate(PackageOrderBase):
    pass

class PackageOrderUpdate(PackageOrderBase):
    work_area_id: Optional[int] = None

class PackageOrder(PackageOrderBase):
    ID: int
    created_at: Optional[datetime] = None
    confirmed_at: Optional[datetime] = None
    created_user_name: Optional[str] = None

    model_config = ConfigDict(
        from_attributes=True,
        populate_by_name=True
    )

class PackageOrderList(BaseSchema):
    items: List[PackageOrder]
    total: int 